<?php

declare (strict_types=1);


namespace App\Models\GameDB\Pet;

use Illuminate\Database\Eloquent\Model;

class SeasonStatistics extends Model
{
    protected $connection = 'mysql_game';
    protected $table = 'lottery_pet_season_statistics';
    protected $guarded = [];

    public function one(array $filters, $orderBy = "id", $sort = 'desc', bool $lock = false)
    {
        $query = self::query()->where($filters);
        $query->orderBy($orderBy, $sort);
        if ($lock) {
            $query->lockForUpdate();
        }

        return $query->first();
    }

    public function updateData(array $filters, array $data)
    {
        return self::query()->where($filters)->update($data);
    }

    public function latestSeason()
    {
        return self::query()->orderBy('season', 'desc')->first(['season']);
    }
}